//
//  ZH_MineClassViewController.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/11/16.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_MineClassViewController.h"
#import "VTMagic.h"
#import "ZH_MineClassInfoViewController.h"
@interface ZH_MineClassViewController ()<VTMagicViewDelegate,VTMagicViewDataSource>
@property (nonatomic, strong) VTMagicController *magicController;
@property (nonatomic, strong) NSMutableArray *menuList;

@end

@implementation ZH_MineClassViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUserInterface];
}

- (void)initUserInterface{
    self.navigationItem.title = @"课程订单";
    self.view.backgroundColor = [UIColor whiteColor];
    self.edgesForExtendedLayout = UIRectEdgeAll;
    [self addChildViewController:self.magicController];
    [self.view addSubview:_magicController.view];
    [self.view setNeedsUpdateConstraints];
    [_magicController.magicView reloadData];
}
#pragma mark - private
//搜索
- (void)search{
    
}
// 菜单标题
- (NSArray<NSString *> *)menuTitlesForMagicView:(VTMagicView *)magicView {
    return self.menuList;
}

// 点击时button变化
- (UIButton *)magicView:(VTMagicView *)magicView menuItemAtIndex:(NSUInteger)itemIndex {
    static NSString *itemIdentifier = @"itemIdentifier";
    UIButton *menuItem = [magicView dequeueReusableItemWithIdentifier:itemIdentifier];
    if (!menuItem) {
        menuItem = [UIButton buttonWithType:UIButtonTypeCustom];
        [menuItem setTitleColor:[UIColor colorWithHexString:@"#999999"] forState:UIControlStateNormal];
        [menuItem setTitleColor:[UIColor colorWithHexString:@"#01CAAF"] forState:UIControlStateSelected];
        menuItem.titleLabel.font = [UIFont fontWithName:@"Helvetica" size:15.f];
    }
    return menuItem;
}
// 点击跳转的视图控制器
- (UIViewController *)magicView:(VTMagicView *)magicView viewControllerAtPage:(NSUInteger)pageIndex{
    ZH_MineClassInfoViewController *vc = [[ZH_MineClassInfoViewController alloc] init];
    vc.statuString = [NSString stringWithFormat:@"%ld",pageIndex];
    return vc;
}

#pragma mark - accessor methods
- (VTMagicController *)magicController {
    if (!_magicController) {
        _magicController = [[VTMagicController alloc] init];
        _magicController.view.translatesAutoresizingMaskIntoConstraints = YES;
        _magicController.magicView.navigationColor = [UIColor whiteColor];//导航栏的颜色
        _magicController.magicView.sliderColor = [UIColor colorWithHexString:@"#01CAAF"];//滑动条的颜色
        _magicController.magicView.switchStyle = VTSwitchStyleDefault;
        _magicController.magicView.layoutStyle = VTLayoutStyleDivide;
        //        _magicController.magicView.navigationHeight = 64.f;
        _magicController.magicView.headerHidden = NO;
        _magicController.magicView.headerHeight = [DATAMODEL KNavigationBarHeioght];
        _magicController.magicView.againstStatusBar = NO;
        _magicController.magicView.sliderExtension = 10.0;
        _magicController.magicView.dataSource = self;
        _magicController.magicView.delegate = self;
        _magicController.magicView.itemScale = 1.1;//点中的item变大
    }
    return _magicController;
}

- (NSMutableArray *)menuList{
    if (!_menuList) {
        _menuList = [[NSMutableArray alloc] initWithCapacity:0];
        [_menuList addObjectsFromArray:@[@"全部",@"代付款",@"待上课",@"已完成"]];
    }
    return _menuList;
}


@end
